use comp_agent::controller::agent_execute_shell::execute_as_user;
use std::io::{self, Write};
// 示例用法
mod unit_test {
    use super::*;

    #[test]
    fn test_execute() {
        let  target_user = "someuser"; // 替换为目标用户名
        let  script = r#"
        echo "Hello from target user!";
        echo "当前目录: $(pwd)";
        ls -l;
    "#;
    match execute_as_user(target_user, script, None) {
        Ok(output) => {
            println!("执行成功:");
            io::stdout().write_all(&output.stdout).unwrap();
        }
        Err(e) => {
            eprintln!("执行失败: {}", e);
        }
    }
    }

}